﻿// GraphWriter.cs
//
// Copyright 2008 by Burt Harris
// Licensed under the Microsoft Public License (Ms-PL)
// See: http://www.codeplex.com/yaml/license
//
using System;

namespace YaTools.Yaml.Serialization
{
    /// <summary>
    /// Defines an abstract class encapsulating presentation
    /// details for data graph serialization a family of 
    /// formats including YAML, JSON and COOR.
    /// </summary>
    abstract public class GraphWriter
    {
        /// <summary>
        /// Type label Uri to write with next item.
        /// </summary>
        /// <remarks>
        /// <para>The TAG property should be set <i>before</i>
        /// calling one of the corresponding Write 
        /// method, or a default tag, generally null,
        /// will be selected for use.  After each Write() 
        /// method is called, the Tag property 
        /// autmoatically reverts to the default value.</para>
        /// </remarks>
        public virtual  Uri Tag { get; set; }

        public abstract void WriteBeginPair();
        public abstract void WriteBeginMapping();
        public abstract void WriteBeginSequence();
        public abstract void WriteBeginDocument();
        public abstract void WriteEnd();

        public abstract void WriteScalar( int scalar );
        public abstract void WriteScalar( bool scalar );
        public abstract void WriteScalar( byte[] scalar );
        public abstract void WriteScalar( string scalar, 
                                          int start, int length );
        public          void WriteScalar( string scalar )
        {
            WriteScalar( scalar, 0, scalar.Length );
        }

        // Comments are an optional feature

        public virtual void WriteComment() {}

    }
}
